package com.report.component;

import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import cn.zhxu.bs.BeanSearcher;
import cn.zhxu.bs.SearchResult;
import cn.zhxu.bs.operator.Equal;
import cn.zhxu.bs.util.MapUtils;
import com.report.dto.request.WebMemberCollectReq;
import com.report.dto.response.WebMemberBrowseRes;
import com.report.entity.Browse;
import com.report.service.IBrowseService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Map;

/**
 * @author summer
 * @date 2024-06-29 10:44
 *
 */
@Service
@Transactional(rollbackFor = Exception.class)
@AllArgsConstructor
public class WebMemberBrowseComponent {

    private final BeanSearcher beanSearcher;



    private final IBrowseService browseService;

    public void saveWebMemberBrowse(WebMemberCollectReq webMemberCollectReq) {
        LambdaQueryWrapper<Browse> eq = Wrappers.lambdaQuery(Browse.class).eq(Browse::getMemberId, webMemberCollectReq.getMemberId());
        Browse one = browseService.getOne(eq);
        if(ObjectUtil.isNull(one)){
            Browse browse = Convert.convert(Browse.class, webMemberCollectReq);
            browseService.save(browse);
        }

    }


}
